﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HuntTheWumpus
{
	class Map
	{
	
       
        Wumpus Wumpus = new Wumpus();
        Room room = new Room();
        Cave cave = new Cave();
        

        private int bat1, bat2;
        private int pit1, pit2;
        private int playerPosition;
        
        public Map()
        {
            setBats();
            setPits();
            readyWumpus();
        }

        public void readyWumpus()
        {
           Random rnd = new Random();

           int pos = rnd.Next(1, 30);

           Wumpus.setPosition(pos);

           Wumpus.setAwake(false);

           Wumpus.setMoving(false);

        }

        public int WumpusLocation()
        {
            int loc = Wumpus.getPosition();
            return loc;
        }

        public void setBats()
        {
            Random rnd = new Random();

            while (bat1 == pit1 || bat2 == pit2 || bat1 == bat2 || bat1 == pit2|| bat2 == 1|| bat1 == 1)
            {
                bat2 = rnd.Next(1, 30);
                bat1 = rnd.Next(1, 30);
            }
        }

        public void moveBat1 ()
        {
   
            Random rnd = new Random();
    
            while (bat1 == pit1 || bat2 == pit2 || bat1 == bat2 || bat1 == pit2)
            {
                bat1 = rnd.Next(1,30);
          
            }
        }

        //checks if room has any hazards
        public bool checkRoomHazards(int room)
        {
            
            if (room == bat1 || room == bat2 || room == pit1 || room == pit2)
            {
                return true;

            }

            else
            {
                return false;
            }
        }

        public void moveBat2()
        {
            Random rnd = new Random();

            while (bat1 == pit1 || bat2 == pit2 || bat1 == bat2 || bat1 == pit2)
            {
                bat2 = rnd.Next(1, 30);
            }
        }

        private void setPits()
        {
            Random rnd = new Random();

            while (pit1 == pit2 || pit1 == bat2 || pit1 == bat1 || pit2 == bat1)
            {
                pit1 = rnd.Next(1, 30);
                pit2 = rnd.Next(1, 30);
            }

        }

        public void moveWumpus()
        {
            if (Wumpus.getAwake() == true)
            {
                int a = Wumpus.getPosition() + 1;
               Wumpus.setPosition(a);
            }

            Wumpus.setMoving(true);
        }

        public int updatePlayerPosition()
        {
            playerPosition = room.getRoomNumber();
            return playerPosition;
        }

        public string sendWarning ()
        {
            //get 
            if (playerPosition + 1 == bat1 || playerPosition + 1 == bat2)
            {
                return "I hear Zubats...";
            }

            else if (playerPosition + 1 == pit1 || playerPosition + 1 == pit2)
            {
                return "Seems like Team Rockets up to no good";
            }

            else if (playerPosition + 1 == Wumpus.getPosition())
            {
                return "The Wumpus is near...";
            }

            else
            {
                return "";
            }
        }


        public string arrowShooting(int shotCave)
        {
          
            if (shotCave == Wumpus.getPosition())
                {
                    return "Wild Wumpus Fainted!";
                }

                else if (shotCave == bat1)
                {
                    moveBat1();
                    return "Wild Zubat fainted";
                    
                }

                else if (shotCave == bat2)
                {
                    moveBat2();
                    return "Wild Zubat fainted!";
                }

                else
                {
                    return "Your attack missed!";
                }
            

        }

        public string checkRoom(int room)
        {
            if (room == Wumpus.getPosition())
            {
                return "At Wumpus";
            }

                else if (room + 1 == Wumpus.getPosition())
                {
                    return "Wumpus near";
                }

            else if (room == bat1 || room == bat2)
            {
                return "At Bat";
            }

                else if (room + 1 == bat1 || room + 1 == bat2)
                {
                    return "Bat near";
                }

            else if (room == pit1 || room == pit2)
            {
                return "At Pit";
            }

                else if (room + 1 == pit1 || room + 1 == pit2)
                {
                    return "Pit near";
                }

            else
            {
                return null;
            }

        }
        
    }


}

